/**
 * Attach 相关逻辑实现类
 * @author WangXinLei
 * @date 2014-11-13
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Attach;
import com.chnbst.bstyun.service.AttachService;

@Transactional
@Service
public class AttachServiceImpl extends BaseService implements AttachService {

	private final static String nameSpace = "com.chnbst.bstyun.mapper.AttachMapper";
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertAttach(Attach attach) {
		return DaoHelper.insert(nameSpace, "insertAttach", attach);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateAttachByAttachId(Attach attach) {
		return DaoHelper.update(nameSpace, "updateAttachByAttachId", attach);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Attach selectAttachByAttachId(Integer attachId) {
		return (Attach)DaoHelper.query(nameSpace, "selectAttachByAttachId", attachId);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@SuppressWarnings("unchecked")
	@Override
	public List<Attach> selectAttachByUserId(Integer userId) {
		return (List<Attach>)DaoHelper.list(nameSpace, "selectAttachByUserId", userId);
	}

	@Override
	public boolean deleteAttachByAttachId(Integer attachId) {
		return DaoHelper.delete(nameSpace, "deleteAttachByAttachId", attachId);
	}

}
